package com.bt.springboot.web.controller;

import com.bt.springboot.common.annotation.LogTrace;
import com.bt.springboot.common.annotation.NoRepeatSubmit;
import com.bt.springboot.common.annotation.OperLog;
import com.bt.springboot.common.enums.ResultEnum;
import com.bt.springboot.common.exception.BusinessException;
import com.bt.springboot.common.result.Result;
import com.bt.springboot.entity.Person;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author zkx
 * @Date 2022/4/8 11:36
 */
@LogTrace
@Slf4j
@RestController
public class TestController {

	@NoRepeatSubmit
	@OperLog
	@GetMapping("/test")
	public void test(Long id){
		log.info("info");
		if (id == null) {
			throw new BusinessException(ResultEnum.ACCESS_DENIED);
		}
	}

	@PostMapping("/testValidate")
	public Result<String> testValidate(@Valid @RequestBody Person person){
		log.info("{}",person);
		return Result.success();
	}

	@GetMapping("/getPerson")
	public Person getPerson(){
		log.info("info");
		Person person = new Person();
		person.setId(1L);
		person.setName("zs");
		person.setPhone("13012340001");
		return person;
	}
}
